package com.str.PQ;
public class HeapSortPeople {

  public static void heapSort(Comparable[] a) {
    PriorityQueue heap = new HeapPriorityQueue();
    for (int i = 0; i < a.length; i++)
      heap.add(a[i]);
    for (int i = 0; i < a.length; i++)
      a[i] = heap.removeMin();
  }
    
  public static void main(String[] args) {
    Person[] students = {
      new Person("Ernest", "Forrest", 1982),
      new Person("Alex", "Wilson", 1981),
      new Person("Susan", "Craw", 1982),
      new Person("David", "Harper", 1981),
      new Person("John", "Usher", 1982),
      new Person("Deryck", "Brown", 1982),
      new Person("James", "Christie", 1981),
      new Person("David", "Davidson", 1982),
      new Person("John", "Mccall", 1981),
      new Person("David", "Simmonds", 1980),
      new Person("Peter", "Strachan", 1980),
      new Person("Jon", "Tyler", 1980),
      new Person("Katherine", "Maguire", 1982),
      new Person("Ines", "Arana", 1981),
      new Person("Christopher", "Macleod", 1981),
      new Person("David", "Crossen", 1980),
      new Person("Audrey", "Fryer", 1980),
      new Person("Ayse", "Goker-Arslan", 1982),
      new Person("Robin", "Grant", 1980),
      new Person("David", "Jason", 1981),
      new Person("David", "Lonie", 1982),
      new Person("Peter", "Lowit", 1981),
      new Person("Roger", "Mcdermott", 1982),
      new Person("David", "Moss", 1980),
      new Person("Robert", "Noble", 1980),
      new Person("Andrei", "Petrovski", 1982),
      new Person("Iain", "Pirie", 1982),
      new Person("Kevin", "Potter", 1982),
      new Person("Apkar", "Salatian", 1981),
      new Person("Derek", "Shirreffs", 1980),
      new Person("Kathleen", "Christie", 1980),
      new Person("Patricia", "Wilson", 1980)
    };

    heapSort(students);
    for (int i = 0; i < students.length; i++)
      System.out.println(students[i]);
  }
}